﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows.Media;


namespace Roboter
{
    class Board
    {
        private Field[,] fields;      
        private int width;

        public int Width
        {
            get { return width; }
            set { width = value; }
        }
        private int height;

        public int Height
        {
            get { return height; }
            set { height = value; }
        }

        internal Field[,] Fields
        {
            get { return fields; }
            set { fields = value; }
        }

        public Board(int width, int height)
        {
            fields = new Field[width,height];
            this.width = width;
            this.height = height;
        }

        public string ToString()
        {
            return "Field " + fields.ToString();
        }

        public void Draw(Canvas drawArea)
        {
            for (int i = 0; i < this.width; i++)
            {
                for (int j = 0; j < this.height; j++)
                {
                    int thickness = 20;
                    Rectangle temp = new Rectangle();
                    temp.Height = thickness;
                    temp.Width = thickness;
                    temp.Stroke = new SolidColorBrush(Colors.Black);
                    temp.StrokeThickness = 1;

                    if (fields[i, j].State == FieldState.blocked)
                    {
                        temp.Fill = new SolidColorBrush(Colors.Blue);
                    }
                    else if (fields[i, j].State == FieldState.robot)
                    {
                        temp.Fill = new SolidColorBrush(Colors.Red);
                    }
                    else
                    {
                        temp.Fill = new SolidColorBrush(Colors.White);
                    }
                    drawArea.Children.Add(temp);
                    temp.SetValue(Canvas.LeftProperty, (double)(i * thickness));
                    temp.SetValue(Canvas.TopProperty, (double)(j * thickness));
                   
                }
            }
        }

    
    }
}
